meta %>%
filter(su_tract == 1) %>%
select(varname, about) %>% as.list()
## $varname
## [1] "avgc_all" "avgc_within150" "avgc_25_employees"
## [4] "avgc_workinRegion" "blkgroup" "tract"
## [7] "county"
##
## $about
## [1] "Average \"as the crow flies\" commuting distance for all workers in the SU"
## [2] "Average \"as the crow flies\" commuting distance for workers in the SU who commute within 150 miles"
## [3] "Average \"as the crow flies\" commuting distance for workers in the SU who commute within the region of interest and those who commute to a census tract outside the region of interest that employs at least 25 residents of the region of interest"
## [4] "Average \"as the crow flies\" commuting distance for workers in the SU who work in the same region"
## [5] "12-digit census block group code"
## [6] "11-digit census tract code"
## [7] "5-digit county code"
glimpse(lodes)
## Rows: 50
## Columns: 6
## $ tract <dbl> 51003010100, 51003010201, 51003010202, 51003010300, …
## $ avgc_workinRegion <dbl> 8.212752, 5.648000, 3.498915, 4.467489, 10.940131, 6…
## $ avgc_within150 <dbl> 26.56022, 19.21498, 21.00497, 20.38666, 24.96775, 21…
## $ avgc_25_employees <dbl> 21.98818, 16.64893, 17.45735, 17.12186, 21.95859, 17…
## $ avgc_all <dbl> 29.66456, 20.58588, 23.01318, 22.90094, 26.26666, 22…
## $ county <int> 51003, 51003, 51003, 51003, 51003, 51003, 51003, 510…
lodes %>% select(avgc_all, avgc_within150, avgc_25_employees, avgc_workinRegion) %>%
select(where(~is.numeric(.x))) %>%
as.data.frame() %>%
stargazer(., type = "text", title = "Summary Statistics", digits = 2,
summary.stat = c("mean", "sd", "min", "median", "max"))
##
## Summary Statistics
## ===================================================
## Statistic Mean St. Dev. Min Median Max
## ---------------------------------------------------
## avgc_all 27.80 9.50 17.34 26.11 72.03
## avgc_within150 24.90 8.13 15.48 23.96 62.91
## avgc_25_employees 21.92 7.95 12.43 19.67 59.50
## avgc_workinRegion 7.71 5.78 1.68 5.54 20.92
## ---------------------------------------------------
lodes %>% select(c(tract, avgc_all, avgc_within150, avgc_25_employees, avgc_workinRegion)) %>%
pivot_longer(-tract, names_to = "measure", values_to = "value") %>%
ggplot(aes(x = value, fill = measure)) +
scale_fill_viridis(option = "plasma", discrete = TRUE, guide = FALSE) +
geom_histogram() +
facet_wrap(~measure, scales = "free")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
meta %>%
filter(varname %in% c("avgc_all", "avgc_within150", "avgc_25_employees", "avgc_workinRegion")) %>%
mutate(label = paste0(varname, ": ", about)) %>%
select(label) %>%
as.list()
$label [1] "avgc_all: Average "as the crow flies" commuting distance for all workers in the SU"
[2] "avgc_within150: Average "as the crow flies" commuting distance for workers in the SU who commute within 150 miles"
[3] "avgc_25_employees: Average "as the crow flies" commuting distance for workers in the SU who commute within the region of interest and those who commute to a census tract outside the region of interest that employs at least 25 residents of the region of interest" [4] "avgc_workinRegion: Average "as the crow flies" commuting distance for workers in the SU who work in the same region"
pal <- colorNumeric("plasma", reverse = T, domain = cvl_lodes$avgc_all)
leaflet(cvl_lodes) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = cvl_lodes,
fillColor = ~pal(avgc_all),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", cvl_lodes$tract, "<br>",
"Average commute (mi): ", round(cvl_lodes$avgc_all, 2))) %>%
addLegend("bottomright", pal = pal, values = cvl_lodes$avgc_all,
title = "Average commute (mi)", opacity = 0.7)
meta %>%
filter(varname %in% c("avgc_all")) %>%
mutate(label = paste0(varname, ": ", about)) %>%
select(label) %>%
as.list()
$label [1] "avgc_all: Average "as the crow flies" commuting distance for all workers in the SU"
pal <- colorNumeric("plasma", reverse = T, domain = cvl_lodes$avgc_within150)
leaflet(cvl_lodes) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = cvl_lodes,
fillColor = ~pal(avgc_within150),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", cvl_lodes$tract, "<br>",
"Average commute (mi): ", round(cvl_lodes$avgc_within150, 2))) %>%
addLegend("bottomright", pal = pal, values = cvl_lodes$avgc_within150,
title = "Average commute (mi)", opacity = 0.7)
meta %>%
filter(varname %in% c("avgc_within150")) %>%
mutate(label = paste0(varname, ": ", about)) %>%
select(label) %>%
as.list()
$label [1] "avgc_within150: Average "as the crow flies" commuting distance for workers in the SU who commute within 150 miles"
pal <- colorNumeric("plasma", reverse = T, domain = cvl_lodes$avgc_25_employees)
leaflet(cvl_lodes) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = cvl_lodes,
fillColor = ~pal(avgc_25_employees),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", cvl_lodes$tract, "<br>",
"Average commute (mi): ", round(cvl_lodes$avgc_25_employees, 2))) %>%
addLegend("bottomright", pal = pal, values = cvl_lodes$avgc_25_employees,
title = "Average commute (mi)", opacity = 0.7)
meta %>%
filter(varname %in% c("avgc_25_employees")) %>%
mutate(label = paste0(varname, ": ", about)) %>%
select(label) %>%
as.list()
$label [1] "avgc_25_employees: Average "as the crow flies" commuting distance for workers in the SU who commute within the region of interest and those who commute to a census tract outside the region of interest that employs at least 25 residents of the region of interest"
pal <- colorNumeric("plasma", reverse = T, domain = cvl_lodes$avgc_workinRegion)
leaflet(cvl_lodes) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = cvl_lodes,
fillColor = ~pal(avgc_workinRegion),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("GEOID: ", cvl_lodes$tract, "<br>",
"Average commute (mi): ", round(cvl_lodes$avgc_workinRegion, 2))) %>%
addLegend("bottomright", pal = pal, values = cvl_lodes$avgc_workinRegion,
title = "Average commute (mi)", opacity = 0.7)
meta %>%
filter(varname %in% c("avgc_workinRegion")) %>%
mutate(label = paste0(varname, ": ", about)) %>%
select(label) %>%
as.list()
$label [1] "avgc_workinRegion: Average "as the crow flies" commuting distance for workers in the SU who work in the same region"